package com.zhiyou.hospital.ssh.dao.impl;

import com.zhiyou.hospital.ssh.dao.IUserDao;
import com.zhiyou.hospital.ssh.model.UserModel;
import com.zhiyou.hospital.ssh.service.IUserService;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;


/**
 * Created by zhouyanchao on 2017/10/17.
 * Descr: 用户管理dao
 */
@Repository
public class UserDaoImpl extends BaseDaoImpl<UserModel> implements IUserDao {

	@Override
	public UserModel getUserByLoginName(String name) {
		Session session = factory.getCurrentSession();

		Query query = session.createQuery("from UserModel where loginName=?");
		query.setParameter(0,name);
		UserModel userModel = (UserModel)query.uniqueResult();

		return userModel;
	}
}
